package day1;
import org.junit.Test;

public class Demo {
	// main
	public static void main(String[] args) {
		// int double char
		// student 可以叫变量、对象
		Student student = new Student();
		//student.id = 2;
		student.setId(1);
		student.setName("张三");
		student.setAge(23);
		student.setGender("男");
		
		int id = student.getId();
		String name = student.getName();
		int age = student.getAge();
		String gender = student.getGender();
		System.out.println("id: " + id + ", name: " + name + ",age:" + age + ",gender: " + gender);
		
		// Student@6d06d69c
		System.out.println(student);
		System.out.println(student.toString());
		
		
	}
	
	@Test
	public void test1() {
		Student student = new Student(1, "张三", 23, "男");
		System.out.println(student);
	}
	
	@Test
	public void test2() {
		Teacher teacher = new Teacher();
		teacher.setId(1);
		teacher.setName("张三");
		teacher.setAge(23);
		teacher.setGender("男");
		teacher.setSalary(1000.0);
		System.out.println(teacher);
	}
	
	@Test
	public void test3() {
		Teacher teacher = new Teacher(1, "李四", 23, "男", 2000);
		System.out.println(teacher);
		teacher.show();
		
		// 声明成父类类型，new子类对象
		// 你继承什么你就是什么
		Person person = new Teacher(2, "王五", 23, "女", 2333);
		// 不管前面声明是子类类型还是父类类型，
		// 如果子类没有覆盖这个show方法，调用的就是就是父类的show方法
		// 如果子类覆盖了父类的show方法，调用的是子类覆盖的show方法
		person.show();
		person.getName();
		// 因为我现在是站在人的角度去看new出来的这个Teacher对象，所以看不到Teacher
		// 里面特有的方法和属性
		//person.getSalary();
	}
	
	@Test
	public void test44() {
		Student student = new Student();
		// setName()这些方法都叫实例方法(必须new出一个对象才能调用的方法)
		student.setName("zhangsan");
		student.show();
		//Student.show();
		
		// 静态方法：小区公共设施，不是属于每个业主
		// 静态方法调用有两种方式
		// 1. 类名.静态方法()
		Student.print();
		// 2. 对象.静态方法()
		student.print();
	}
	
	@Test
	public void test5() {
		// 前台给我们的数据都是以字符串形式，pageSize=5
		// NumberFormatException: For input string: "5f"
		// String pageSize = "5f";
		 String pageSize = "5";
		int ps = Integer.parseInt(pageSize);
		System.out.println(ps);
	}
	
	
	
	
	
	
	
	
}
